﻿
using System;
using System.ComponentModel;
using System.Threading;
using Silverlight.Training.Client.Common.ServiceReference.Contracts;
using Silverlight.Training.Client.Common.ServiceReference.EventArgs;
using Silverlight.Training.Client.Common.ServiceReference.Feedbacks;
using Silverlight.Training.Client.Common.ServiceReference.Interfaces;

namespace Silverlight.Training.Client.Common.ServiceReference.Operations
{
    public partial class EMServiceClient
    {
        #region GetJobTitleCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<JobTitle>> GetJobTitleCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IEMService.BeginGetJobTitleCollection(AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetJobTitleCollection(callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<JobTitle> IEMService.EndGetJobTitleCollection(IAsyncResult result)
        {
            return base.Channel.EndGetJobTitleCollection(result);
        }

        private IAsyncResult OnBeginGetJobTitleCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            return ((IEMService)(this)).BeginGetJobTitleCollection(callback, asyncState);
        }

        private object[] OnEndGetJobTitleCollection(IAsyncResult result)
        {
            CollectionFeedback<JobTitle> retVal = ((IEMService)(this)).EndGetJobTitleCollection(result);
            return new object[] {
                retVal};
        }

        private void OnGetJobTitleCollectionCompleted(object state)
        {
            if ((this.GetJobTitleCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetJobTitleCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<JobTitle>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetJobTitleCollectionAsync()
        {
            this.GetJobTitleCollectionAsync(null);
        }

        public void GetJobTitleCollectionAsync(object userState)
        {
            if ((this.onBeginGetJobTitleCollectionDelegate == null))
            {
                this.onBeginGetJobTitleCollectionDelegate = new BeginOperationDelegate(this.OnBeginGetJobTitleCollection);
            }
            if ((this.onEndGetJobTitleCollectionDelegate == null))
            {
                this.onEndGetJobTitleCollectionDelegate = new EndOperationDelegate(this.OnEndGetJobTitleCollection);
            }
            if ((this.onGetJobTitleCollectionCompletedDelegate == null))
            {
                this.onGetJobTitleCollectionCompletedDelegate = new SendOrPostCallback(this.OnGetJobTitleCollectionCompleted);
            }
            base.InvokeAsync(this.onBeginGetJobTitleCollectionDelegate, null, this.onEndGetJobTitleCollectionDelegate, this.onGetJobTitleCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetJobTitleCollectionDelegate;

        private EndOperationDelegate onEndGetJobTitleCollectionDelegate;

        private SendOrPostCallback onGetJobTitleCollectionCompletedDelegate;

        private partial class EMServiceClientChannel
        {
            public IAsyncResult BeginGetJobTitleCollection(AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[0];
                IAsyncResult _result = base.BeginInvoke("GetJobTitleCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<JobTitle> EndGetJobTitleCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<JobTitle> _result = ((CollectionFeedback<JobTitle>)(base.EndInvoke("GetJobTitleCollection", _args, result)));
                return _result;
            }
        }

        #endregion

        #region GetSingleJobTitle

        public event EventHandler<SingleFeedbackCompletedEventArgs<JobTitle>> GetSingleJobTitleCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IEMService.BeginGetSingleJobTitle(int jTitleID, AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetSingleJobTitle(jTitleID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<JobTitle> IEMService.EndGetSingleJobTitle(IAsyncResult result)
        {
            return base.Channel.EndGetSingleJobTitle(result);
        }

        private IAsyncResult OnBeginGetSingleJobTitle(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int jTitleID = ((int)(inValues[0]));
            return ((IEMService)(this)).BeginGetSingleJobTitle(jTitleID, callback, asyncState);
        }

        private object[] OnEndGetSingleJobTitle(IAsyncResult result)
        {
            SingleFeedback<JobTitle> retVal = ((IEMService)(this)).EndGetSingleJobTitle(result);
            return new object[] {
                retVal};
        }

        private void OnGetSingleJobTitleCompleted(object state)
        {
            if ((this.GetSingleJobTitleCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetSingleJobTitleCompleted(this, new SingleFeedbackCompletedEventArgs<JobTitle>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleJobTitleAsync(int jTitleID)
        {
            this.GetSingleJobTitleAsync(jTitleID, null);
        }

        public void GetSingleJobTitleAsync(int jTitleID, object userState)
        {
            if ((this.onBeginGetSingleJobTitleDelegate == null))
            {
                this.onBeginGetSingleJobTitleDelegate = new BeginOperationDelegate(this.OnBeginGetSingleJobTitle);
            }
            if ((this.onEndGetSingleJobTitleDelegate == null))
            {
                this.onEndGetSingleJobTitleDelegate = new EndOperationDelegate(this.OnEndGetSingleJobTitle);
            }
            if ((this.onGetSingleJobTitleCompletedDelegate == null))
            {
                this.onGetSingleJobTitleCompletedDelegate = new SendOrPostCallback(this.OnGetSingleJobTitleCompleted);
            }
            base.InvokeAsync(this.onBeginGetSingleJobTitleDelegate, new object[] {
                    jTitleID}, this.onEndGetSingleJobTitleDelegate, this.onGetSingleJobTitleCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleJobTitleDelegate;

        private EndOperationDelegate onEndGetSingleJobTitleDelegate;

        private SendOrPostCallback onGetSingleJobTitleCompletedDelegate;

        private partial class EMServiceClientChannel
        {
            public IAsyncResult BeginGetSingleJobTitle(int jTitleID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = jTitleID;
                IAsyncResult _result = base.BeginInvoke("GetSingleJobTitle", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<JobTitle> EndGetSingleJobTitle(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<JobTitle> _result = ((SingleFeedback<JobTitle>)(base.EndInvoke("GetSingleJobTitle", _args, result)));
                return _result;
            }
        }

        #endregion
    }
}
